let fs = require("fs");
let path = require("path");
let express = require("express");
let app = express();
app.use(express.urlencoded({ extended: false })); 
app.use(express.json())

app.get("/login", (req, res) => {
    let url = path.join(__dirname , "/view/login.html");
    let data = fs.readFileSync(url);
    res.end(data);
})

app.post("/login",(req,res) =>{
    let {tel,pass} = req.body;
    console.log(req.body);
    if (tel == "17799096434" && pass == "123456") {
        res.send("登录成功")
    } else {
        res.send("登陆失败")
    }
})

app.get("/register", (req, res) => {
    let url = path.join(__dirname , "/view/register.html");
    let data = fs.readFileSync(url);
    res.end(data);
})

app.post("/register",(req,res) =>{
    let {tel,pass} = req.body;
    if (tel == "17799096434") {
        res.send("用户已存在")
    } else {
        res.send("用户可以注册")
    }
})

app.listen(4000,"127.0.0.1",()=>{
    console.log("启动");
})